home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
clp_v11.zip
/
CLP.DOC
next >
Wrap
Text File
|
1989-10-14
|
21KB
|
577 lines
CLP - A 'C' Command Line Processor, Version 1.1
-------------------------------------------------
*****************************************************************
* *
* This archived software set is shareware! It is NOT public- *
* domain, and though it is free of charge it may only be *
* distributed with the following conditions: *
* *
* 1. The full archive CLP_V11.ARC is distributed without *
* modification. *
* 2. No commercial gain is directly sought from any of *
* the files contained within the archive without the *
* author's prior approval. *
* 3. Notification should be sent to the Author (name & *
* address & e-Mail address below) of any use of CLP *
* in programs outside the individual's personal use. *
* This includes public-domain and shareware software *
* as well as commercial software. *
* *
* Users requiring versions of CLP for different memory models *
* should send a postage paid reply envelope to the address *
* below. Registering may also be accomplished by sending a *
* diskette (360K, 1.2M, 740K, 1.44M) to the address below. In *
* reply, you will receive the latest version of CLP for all *
* memory models, the complete CLPLIB utility and instructions *
* for linking CLP definitions into code directly without the *
* need for a library. *
* *
* Please ensure that the reply envelope has enough postage to *
* cover costs. Instead of postage, you may send a 1.44M *
* diskette! Gets around the international stamp system! *
* *
*- - - - - - - - - - - - - - - - - - - - - *
* *
* Queries, comments, suggestions & registration to: *
* *
* Karl Keyte, e-Mail: ESC1332@ESOC.BITNET *
* E.S.O.C., Phone : +(49) 6151 886783 *
* Robert-Bosch Strasse 5, *
* 6100 Darmstadt *
* West Germany Date : September 1989 *
* *
*****************************************************************
1 Introduction
------------
CLP is a general purpose command line processor for the 'C'
language. Looking at the sources for various programs written in
'C' it is clear that a lot of work has been repeated in handling
command line options and parameters. CLP provides a means by
which the general format of the command line may be defined in a
Command Line Definition file (.CLD), and processed by a single
interface call. Following that call, values and settings of
parameters and switches may be queried by additional calls. The
idea and much of the flavour of CLP comes from the VAX/VMS
operating system, where command definitions may be build up in a
very similar fashion.
CLP has been tested with Turbo-C (2.0) and Microsoft C (5.1). The
'#include' file given conforms to ANSI standards, and should
therefore be accepted by any ANSI compiler. The object module
uses a standard 'C' parameter stack.
A compiler is provided which takes the Command Line Definition
file and generates a Command Line Library (.CLL) file which
contains definitions for ALL utilities using the CLP interface.
The .CLD file should be maintained by adding and deleting
utilities from it as required. Running the compiler will generate
the full Library file (.CLL) from the definitions.
Four functions are available to the caller. 'clp_accept'
initialises the CLP processor for a given program and command
line. 'clp_get_spec' returns the specification code for a
particular parameter or switch option. 'clp_get_value' returns
the value associated with a parameter or switch option if
present. These are described in detail in the following sections.
When parameter and switch processing has been completed, the user
may recover certain portions of system memory by calling the
procedure 'clp_release'.
2 Interface Calls
---------------
2.1 clp_accept
----------
Function:
Initialise CLP for specified program and command line.
Syntax:
#include "clp.h"
void clp_accept ( char *function, int argc, char argv** );
Prototype:
clp.h
Remarks:
Sets up the data structures in preparation for other
interface calls. 'function' specifies the program name, as
given in the CLD file. 'argc' and 'argv' are the command
line parameters of the main program, and should be passed
to 'clp_accept' exactly as they were received.
If the command specified does not conform to the
definition in the CLD, the program will exit with the exit
status of 1.
'clp_accept' attempts to open the CLL library file by
checking first the environment variable CLPLIB. If this is
defined, the file given will be used. If the environment
variable is undefined, 'clp_accept' attempts to locate the
file CLP.CLL in the current searchpath. If it is not
found, the program will exit with an exit code of 1.
Return Value:
None.
2.2 clp_get_spec
------------
Function:
Returns the specification code for a specified parameter
or switch option.
Syntax:
#include "clp.h"
int clp_get_spec ( char *name );
Remarks:
Finds the specification associated with the switch or
parameter 'name'. The name must be present in the CLD
file.
Return Value:
The return is one of the following:
CLP_ERROR Not found, i.e. was not
defined in the CLD file.
CLP_NOTSPECIFIED Not specified in the command
line.
CLP_DEFAULTED Not specified in the command
line but is on by default.
CLP_SPECIFIED Explicitly specified in
command line.
CLP_VALUEDEFAULTED Contains a value which has
been defaulted.
CLP_VALUESPECIFIED Contains a value which has
been explicitly specified.
CLP_NEGATED Explicitly negated.
2.3 clp_get_value
-------------
Function:
Returns the value associated with a parameter or value
switch option.
Syntax:
#include "clp.h"
char *clp_get_value ( char *name );
Remarks:
Finds the value asociated with the specified parameter or
switch option, 'name'. The name must be present in the CLD
file.
Return Value:
Returns a pointer to the value string. The string is
static, and must be copied by the user if it is to be
further used. NULL is returned if no value is defined, or
if the 'name' specifies an invalid parameter or switch
name.
2.4 clp_release
-----------
Function:
Releases all memory reserved by the CLP processor.
Syntax:
#include "clp.h"
void clp_release ( void );